<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: MoBANCoordinator Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00142.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pro-types">Protected Types</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">MoBANCoordinator Class Reference<div class="ingroups"><a class="el" href="a00513.html">mobility - modules handling the mobility of the hosts</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="MoBANCoordinator" --><!-- doxytag: inherits="LineSegmentsMobilityBase" -->
<p>This is the coordinator module of the MoBAN mobility model. It should be instantiated in the top level simulation network, once per WBAN. The coordinator module is the main module that provides the group mobility and correlation between nodes in a WBAN. In the initialization phase, it reads three user defined input files which are the postures specification file, a configuration file which includes all required parameter for specific distributions, and the previously logged mobility pattern, if it is requested to use a logged pattern. Note that all WBAN instances may use the same input files if they are exactly in the same situation.  
 <a href="a00142.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00357_source.html">MoBANCoordinator.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for MoBANCoordinator:</div>
<div class="dyncontent">
<div class="center"><img src="a00867.png" border="0" usemap="#MoBANCoordinator_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for MoBANCoordinator:</div>
<div class="dyncontent">
<div class="center"><img src="a00868.png" border="0" usemap="#MoBANCoordinator_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00869.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00171.html">pattern</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Data type for one instance of mobility pattern.  <a href="a00171.html#details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-types"></a>
Protected Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a891080762617c76085a1c4cd618fbb93">posture_sel_type</a> { <b>UNIFORM_RANDOM</b> =  0, 
<b>MARKOV_BASE</b>
 }</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Possible (supported) strategies for posture selection. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aba7c0480967381f3cb5c09b05029abe7"></a><!-- doxytag: member="MoBANCoordinator::Pattern" ref="aba7c0480967381f3cb5c09b05029abe7" args="" -->
typedef struct <br class="typebreak"/>
<a class="el" href="a00171.html">MoBANCoordinator::pattern</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#aba7c0480967381f3cb5c09b05029abe7">Pattern</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Data type for one instance of mobility pattern. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9e116be526a0d4f1f4482728f32c237c"></a><!-- doxytag: member="MoBANCoordinator::initialize" ref="a9e116be526a0d4f1f4482728f32c237c" args="(int)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a9e116be526a0d4f1f4482728f32c237c">initialize</a> (int)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes mobility model parameters. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae4a1b3a24c63d32ff44a92d58633ce06"></a><!-- doxytag: member="MoBANCoordinator::initializePosition" ref="ae4a1b3a24c63d32ff44a92d58633ce06" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#ae4a1b3a24c63d32ff44a92d58633ce06">initializePosition</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes the position from the display string or from module parameters. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a9f2559857f8062a663d8672187a18a1a">setTargetPosition</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Set a new target position from the next posture.  <a href="#a9f2559857f8062a663d8672187a18a1a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8c01318d39ee0023d3b952edff5864a9"></a><!-- doxytag: member="MoBANCoordinator::findVisualRepresentation" ref="a8c01318d39ee0023d3b952edff5864a9" args="()" -->
virtual cModule *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a8c01318d39ee0023d3b952edff5864a9">findVisualRepresentation</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the module that represents the object moved by this mobility module. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3746b224f6ff4655f5618c5c48bb6c48"></a><!-- doxytag: member="MoBANCoordinator::finish" ref="a3746b224f6ff4655f5618c5c48bb6c48" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a3746b224f6ff4655f5618c5c48bb6c48">finish</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">To be called at the end of simulation run. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#ab622d4b167d9d5dbc7529969a6688597">selectPosture</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to select the next posture considering the current posture and the Markov model.  <a href="#ab622d4b167d9d5dbc7529969a6688597"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00065.html">Coord</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#adebee0a447b7e85d444054fa3a4ee013">selectDestination</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to select the destination in the case of a mobile posture.  <a href="#adebee0a447b7e85d444054fa3a4ee013"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a6d83b8c03d91b0fee3e335b214f51b4c">selectSpeed</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Select a velocity value within the given velocity range.  <a href="#a6d83b8c03d91b0fee3e335b214f51b4c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#ab4f9d86a51c84b083817db1fcbe9dbab">selectDuration</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Select a stay time duration in the specified range for the new posture.  <a href="#ab4f9d86a51c84b083817db1fcbe9dbab"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#aa9e9424cb4572715a8f5b042aa4155d0">isInsideWorld</a> (<a class="el" href="a00065.html">Coord</a>)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks if all nodes of the WBAN are inside the simulation environment with the given position of the logical center.  <a href="#aa9e9424cb4572715a8f5b042aa4155d0"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#aab85ba2010884afd66f619718e1194d7">readPostureSpecificationFile</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Reading the input postures specification file and making the posture data base.  <a href="#aab85ba2010884afd66f619718e1194d7"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a138ebd67882d6cf1154126f47d35d49c">readConfigurationFile</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads the input configuration file.  <a href="#a138ebd67882d6cf1154126f47d35d49c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a31810405333b184c9db891fa9bd8a12a">readMobilityPatternFile</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads the previously logged mobility pattern and make mobility pattern data base.  <a href="#a31810405333b184c9db891fa9bd8a12a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7e5b78357b30b23f2f8285dcde5c6dd9"></a><!-- doxytag: member="MoBANCoordinator::publishToNodes" ref="a7e5b78357b30b23f2f8285dcde5c6dd9" args="()" -->
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a7e5b78357b30b23f2f8285dcde5c6dd9">publishToNodes</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Publishes the reference point and other information of the posture to the blackboard of the belonging nodes. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a67d84600268cd3325298fd0f3afc964f"></a><!-- doxytag: member="MoBANCoordinator::collectLocalModules" ref="a67d84600268cd3325298fd0f3afc964f" args="(cModule *module)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a67d84600268cd3325298fd0f3afc964f">collectLocalModules</a> (cModule *module)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Collect MoBAN local modules. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a357c9f724ee27d0c33a1543e650b9e48"></a><!-- doxytag: member="MoBANCoordinator::localModules" ref="a357c9f724ee27d0c33a1543e650b9e48" args="" -->
std::vector&lt; <a class="el" href="a00143.html">MoBANLocal</a> * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a357c9f724ee27d0c33a1543e650b9e48">localModules</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The mobility modules of the nodes in this WBAN. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afdfb553fa2576a3e72a6111b12f14a97"></a><!-- doxytag: member="MoBANCoordinator::speed" ref="afdfb553fa2576a3e72a6111b12f14a97" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#afdfb553fa2576a3e72a6111b12f14a97">speed</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Currently selected speed for the mobile posture. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abb700aed062784b7cb21eec3e146c80d"></a><!-- doxytag: member="MoBANCoordinator::logfile" ref="abb700aed062784b7cb21eec3e146c80d" args="" -->
FILE *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#abb700aed062784b7cb21eec3e146c80d">logfile</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to the file for logging MoBAN mobility pattern for future use. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3880f0e3e0e489b1edd2692a441b903f"></a><!-- doxytag: member="MoBANCoordinator::numPostures" ref="a3880f0e3e0e489b1edd2692a441b903f" args="" -->
unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f">numPostures</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of predefined postures. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afbb28bcb93bda1faadc7030d86be43b5"></a><!-- doxytag: member="MoBANCoordinator::postureList" ref="afbb28bcb93bda1faadc7030d86be43b5" args="" -->
std::vector&lt; <a class="el" href="a00178.html">Posture</a> * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5">postureList</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The list of all predefined postures (posture data base) <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a19a97a40859c36012f3a63a7c9ef9b46"></a><!-- doxytag: member="MoBANCoordinator::currentPosture" ref="a19a97a40859c36012f3a63a7c9ef9b46" args="" -->
<a class="el" href="a00178.html">Posture</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46">currentPosture</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The current selected posture. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aac48e46d43458a8f960cc33e84ac85e8"></a><!-- doxytag: member="MoBANCoordinator::minDuration" ref="aac48e46d43458a8f960cc33e84ac85e8" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#aac48e46d43458a8f960cc33e84ac85e8">minDuration</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The minimum value of the duration for stable postures. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a02c4e8d23a6b0b2e1a1d94abe1974b9f"></a><!-- doxytag: member="MoBANCoordinator::maxDuration" ref="a02c4e8d23a6b0b2e1a1d94abe1974b9f" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a02c4e8d23a6b0b2e1a1d94abe1974b9f">maxDuration</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The maximum value of the duration for stable postures. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6f67cb3412735ec31734d8a345688e5b"></a><!-- doxytag: member="MoBANCoordinator::useMobilityPattern" ref="a6f67cb3412735ec31734d8a345688e5b" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a6f67cb3412735ec31734d8a345688e5b">useMobilityPattern</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Variable that shows if reusing previously logged mobility pattern is requested. The value is gotten from the parameter of the module. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae19a9a2dce220a75c4757381b5f348a7"></a><!-- doxytag: member="MoBANCoordinator::mobilityPattern" ref="ae19a9a2dce220a75c4757381b5f348a7" args="" -->
<a class="el" href="a00142.html#aba7c0480967381f3cb5c09b05029abe7">Pattern</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#ae19a9a2dce220a75c4757381b5f348a7">mobilityPattern</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The mobility pattern data base. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a00cbcb40ee4039ffd5723ffa4334d88f"></a><!-- doxytag: member="MoBANCoordinator::patternLength" ref="a00cbcb40ee4039ffd5723ffa4334d88f" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a00cbcb40ee4039ffd5723ffa4334d88f">patternLength</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The number of mobility pattern instances which has been read from the input file (length of mobility pattern data base). <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aeff87bd9af8cb9aa14eada4b73ec4fbe"></a><!-- doxytag: member="MoBANCoordinator::currentPattern" ref="aeff87bd9af8cb9aa14eada4b73ec4fbe" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#aeff87bd9af8cb9aa14eada4b73ec4fbe">currentPattern</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The index of the currently applied mobility pattern from. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a406987de5c4e38c461e0857583c115b2"></a><!-- doxytag: member="MoBANCoordinator::markovMatrix" ref="a406987de5c4e38c461e0857583c115b2" args="" -->
double **&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a406987de5c4e38c461e0857583c115b2">markovMatrix</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">A matrix which maintains the transition probabilities of the Markov Model of posture pattern. To be given through configuration file. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a626ad8d08de1e3d7fad2c8032f199933"></a><!-- doxytag: member="MoBANCoordinator::postureSelStrategy" ref="a626ad8d08de1e3d7fad2c8032f199933" args="" -->
<a class="el" href="a00142.html#a891080762617c76085a1c4cd618fbb93">posture_sel_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a626ad8d08de1e3d7fad2c8032f199933">postureSelStrategy</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The requested strategy for posture selection. To be given through configuration file. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a51f9fc44b5168e7ef6e58fd221bf3f0a"></a><!-- doxytag: member="MoBANCoordinator::transitions" ref="a51f9fc44b5168e7ef6e58fd221bf3f0a" args="" -->
<a class="el" href="a00179.html">PostureTransition</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#a51f9fc44b5168e7ef6e58fd221bf3f0a">transitions</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Class for performing operation for spatial and temporal correlations in posture selection. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>This is the coordinator module of the MoBAN mobility model. It should be instantiated in the top level simulation network, once per WBAN. The coordinator module is the main module that provides the group mobility and correlation between nodes in a WBAN. In the initialization phase, it reads three user defined input files which are the postures specification file, a configuration file which includes all required parameter for specific distributions, and the previously logged mobility pattern, if it is requested to use a logged pattern. Note that all WBAN instances may use the same input files if they are exactly in the same situation. </p>
<p>After the initialization phase, the MoBAN coordinator decides about the posture and the position of the Logical center of the group (WBAN). The absolute position of the reference point of each belonging node is calculated by adding the current position of the logical center by the reference point of that node in the selected posture. The coordinator sets the position of the reference point as well as the speed and the radius of the local movement of nodes.</p>
<dl class="author"><dt><b>Author:</b></dt><dd>Majid Nabi </dd></dl>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="aa9e9424cb4572715a8f5b042aa4155d0"></a><!-- doxytag: member="MoBANCoordinator::isInsideWorld" ref="aa9e9424cb4572715a8f5b042aa4155d0" args="(Coord)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool MoBANCoordinator::isInsideWorld </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00065.html">Coord</a>&#160;</td>
          <td class="paramname"><em>tPos</em></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Checks if all nodes of the WBAN are inside the simulation environment with the given position of the logical center. </p>
<p>Checks if all nodes of the WBAN are inside the simulation environment with the current position. </p>

<p>References <a class="el" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46">currentPosture</a>, <a class="el" href="a00178.html#a6cce5bfb2a17e71e346d7fd699139820">Posture::getPs()</a>, <a class="el" href="a00065.html#a7a42e29d7a15ed0b53e47137549e00a6">Coord::isInBoundary()</a>, and <a class="el" href="a00142.html#a357c9f724ee27d0c33a1543e650b9e48">localModules</a>.</p>

<p>Referenced by <a class="el" href="a00142.html#adebee0a447b7e85d444054fa3a4ee013">selectDestination()</a>.</p>
<div class="fragment"><pre class="fragment">                                               {
    <a class="code" href="a00065.html" title="Class for storing 3D coordinates.">Coord</a> absolutePosition;

    <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="a00142.html#a357c9f724ee27d0c33a1543e650b9e48" title="The mobility modules of the nodes in this WBAN.">localModules</a>.size(); ++i) {
        absolutePosition = tPos + <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a6cce5bfb2a17e71e346d7fd699139820" title="Returns the relative position of a node in this posture.">getPs</a>(i);
        <span class="keywordflow">if</span> (!absolutePosition.<a class="code" href="a00065.html#a7a42e29d7a15ed0b53e47137549e00a6" title="Checks if this coordinate is inside a specified rectangle.">isInBoundary</a>(this-&gt;constraintAreaMin, this-&gt;constraintAreaMax))
            <span class="keywordflow">return</span> <span class="keyword">false</span>;
    }

    <span class="keywordflow">return</span> <span class="keyword">true</span>;
}
</pre></div>
</div>
</div>
<a class="anchor" id="a138ebd67882d6cf1154126f47d35d49c"></a><!-- doxytag: member="MoBANCoordinator::readConfigurationFile" ref="a138ebd67882d6cf1154126f47d35d49c" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool MoBANCoordinator::readConfigurationFile </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Reads the input configuration file. </p>
<p>Function to read the configuration file which includes the information for configuring and tuning the model for a specific application scenario. The configuration file can provide the Markov model transition matrices, different area types and time domains, and the proper matrix for each time-space combination. However, these are all optional and will be given just in the case that the space-time correlation are required to be simulated. The function will be called in the initialization phase. </p>

<p>References <a class="el" href="a00179.html#a261ad915b2a9c7cdf7082660360190e4">PostureTransition::addAreaType()</a>, <a class="el" href="a00179.html#a5b4ab00961c0039aac63143d28e88272">PostureTransition::addCombination()</a>, <a class="el" href="a00179.html#a10abfb612543bbc52f6a13a0e138d822">PostureTransition::addMatrix()</a>, <a class="el" href="a00179.html#ac5c424a8372a3d6f39ccc06c88d4249f">PostureTransition::addSteadyState()</a>, <a class="el" href="a00179.html#a58c7924dfb8810ba37311217a7ba5c8d">PostureTransition::addTimeDomain()</a>, <a class="el" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46">currentPosture</a>, <a class="el" href="a00178.html#a40dc6d7007b14e779420da389e927aec">Posture::getPostureName()</a>, <a class="el" href="a00065.html#a86994bfa7096155d951abb03dcf30bf1">Coord::info()</a>, <a class="el" href="a00145.html#a82ae637969433a492154b26039b84038">MobilityBase::lastPosition</a>, <a class="el" href="a00142.html#a02c4e8d23a6b0b2e1a1d94abe1974b9f">maxDuration</a>, <a class="el" href="a00142.html#aac48e46d43458a8f960cc33e84ac85e8">minDuration</a>, <a class="el" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f">numPostures</a>, <a class="el" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5">postureList</a>, <a class="el" href="a00142.html#a626ad8d08de1e3d7fad2c8032f199933">postureSelStrategy</a>, <a class="el" href="a00179.html#a309ed6acf7eca6469f0ea0f06ee41780">PostureTransition::setAreaBoundry()</a>, <a class="el" href="a00179.html#af66d8f9dda835d55dc3009cf582f87d8">PostureTransition::setTimeBoundry()</a>, and <a class="el" href="a00142.html#a51f9fc44b5168e7ef6e58fd221bf3f0a">transitions</a>.</p>

<p>Referenced by <a class="el" href="a00142.html#a9e116be526a0d4f1f4482728f32c237c">initialize()</a>.</p>
<div class="fragment"><pre class="fragment">                                             {
    cXMLElement* xmlConfig = par(<span class="stringliteral">&quot;configFile&quot;</span>).xmlValue();
    <span class="keywordflow">if</span> (xmlConfig == 0)
        <span class="keywordflow">return</span> <span class="keyword">false</span>;

    cXMLElementList tagList;
    cXMLElement* tempTag;
    <span class="keyword">const</span> <span class="keywordtype">char</span>* str;
    std::string sstr; <span class="comment">// for easier comparison</span>

    <span class="comment">/* Reading the initial posture if it is given*/</span>
    <span class="keywordtype">int</span> postureID;
    tagList = xmlConfig-&gt;getElementsByTagName(<span class="stringliteral">&quot;initialPosture&quot;</span>);

    <span class="keywordflow">if</span> (tagList.empty())
        postureID = 0; <span class="comment">// no initial posture has been specified. The first one is selected!</span>
    <span class="keywordflow">else</span> {
        tempTag = tagList.front();
        str = tempTag-&gt;getAttribute(<span class="stringliteral">&quot;postureID&quot;</span>);
        postureID = strtol(str, 0, 0);
    }
    <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a> = <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[postureID];
    EV &lt;&lt; <span class="stringliteral">&quot;Initial Posture: &quot;</span> &lt;&lt; <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a40dc6d7007b14e779420da389e927aec" title="Returns posture name.">getPostureName</a>() &lt;&lt; endl;

    <span class="comment">/* Reading the initial position if it is given */</span>
    tagList = xmlConfig-&gt;getElementsByTagName(<span class="stringliteral">&quot;initialLocation&quot;</span>);
    <span class="keywordflow">if</span> (tagList.empty())
        <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a> = <a class="code" href="a00065.html" title="Class for storing 3D coordinates.">Coord</a>(10,10,5); <span class="comment">// no initial location has been specified .</span>
    <span class="keywordflow">else</span>
    {
        <span class="keywordtype">double</span> x,y,z;
        tempTag= tagList.front();

        str = tempTag-&gt;getAttribute(<span class="stringliteral">&quot;x&quot;</span>); x = strtod(str, 0);
        str = tempTag-&gt;getAttribute(<span class="stringliteral">&quot;y&quot;</span>); y = strtod(str, 0);
        str = tempTag-&gt;getAttribute(<span class="stringliteral">&quot;z&quot;</span>); z = strtod(str, 0);
        <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a> = <a class="code" href="a00065.html" title="Class for storing 3D coordinates.">Coord</a>(x,y,z);
    }
    EV &lt;&lt; <span class="stringliteral">&quot;Initial position of the LC: &quot;</span> &lt;&lt; <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.<a class="code" href="a00065.html#a86994bfa7096155d951abb03dcf30bf1" title="Returns a string with the value of the coordinate.">info</a>() &lt;&lt; endl;

    <span class="comment">/* Reading the given range for duration of stable postures */</span>
    tagList = xmlConfig-&gt;getElementsByTagName(<span class="stringliteral">&quot;durationRange&quot;</span>);
    <span class="keywordflow">if</span> (tagList.empty())
    {
        <span class="comment">// no duration is specified. We assign a value!</span>
        <a class="code" href="a00142.html#aac48e46d43458a8f960cc33e84ac85e8" title="The minimum value of the duration for stable postures.">minDuration</a> = 0;
        <a class="code" href="a00142.html#a02c4e8d23a6b0b2e1a1d94abe1974b9f" title="The maximum value of the duration for stable postures.">maxDuration</a> = 100;
    }
    <span class="keywordflow">else</span>
    {
        tempTag= tagList.front();

        str = tempTag-&gt;getAttribute(<span class="stringliteral">&quot;min&quot;</span>);
        <a class="code" href="a00142.html#aac48e46d43458a8f960cc33e84ac85e8" title="The minimum value of the duration for stable postures.">minDuration</a> = strtod(str, 0);
        str = tempTag-&gt;getAttribute(<span class="stringliteral">&quot;max&quot;</span>);
        <a class="code" href="a00142.html#a02c4e8d23a6b0b2e1a1d94abe1974b9f" title="The maximum value of the duration for stable postures.">maxDuration</a> = strtod(str, 0);
    }
    EV &lt;&lt; <span class="stringliteral">&quot;Posture duration range: (&quot;</span> &lt;&lt; <a class="code" href="a00142.html#aac48e46d43458a8f960cc33e84ac85e8" title="The minimum value of the duration for stable postures.">minDuration</a> &lt;&lt; <span class="stringliteral">&quot; , &quot;</span> &lt;&lt; <a class="code" href="a00142.html#a02c4e8d23a6b0b2e1a1d94abe1974b9f" title="The maximum value of the duration for stable postures.">maxDuration</a> &lt;&lt; <span class="stringliteral">&quot;)&quot;</span> &lt;&lt; endl;

    <a class="code" href="a00142.html#a51f9fc44b5168e7ef6e58fd221bf3f0a" title="Class for performing operation for spatial and temporal correlations in posture selection.">transitions</a> = <span class="keyword">new</span> <a class="code" href="a00179.html" title="Class to provide spatial and temporal correlation in the posture selection process of the MoBAN mobil...">PostureTransition</a>(<a class="code" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f" title="Number of predefined postures.">numPostures</a>);

    <span class="comment">/* Reading the Markov transition matrices, if there are any. */</span>
    tagList = xmlConfig-&gt;getElementsByTagName(<span class="stringliteral">&quot;markovMatrices&quot;</span>);

    <span class="keywordflow">if</span> (tagList.empty())
    {
        <a class="code" href="a00142.html#a626ad8d08de1e3d7fad2c8032f199933" title="The requested strategy for posture selection. To be given through configuration file.">postureSelStrategy</a> = UNIFORM_RANDOM; <span class="comment">// no posture selection strategy is required. uniform random is applied</span>
        EV &lt;&lt; <span class="stringliteral">&quot;Posture Selection strategy: UNIFORM_RANDOM &quot;</span> &lt;&lt; endl;
        <span class="keywordflow">return</span> <span class="keyword">true</span>;
    }

    tempTag = tagList.front();

    cXMLElementList matrixList;
    matrixList = tempTag-&gt;getElementsByTagName(<span class="stringliteral">&quot;MarkovMatrix&quot;</span>);

    <span class="keywordflow">if</span> (tagList.empty())
    {
        <a class="code" href="a00142.html#a626ad8d08de1e3d7fad2c8032f199933" title="The requested strategy for posture selection. To be given through configuration file.">postureSelStrategy</a> = UNIFORM_RANDOM; <span class="comment">// no posture selection strategy is required. uniform random is applied</span>
        EV &lt;&lt; <span class="stringliteral">&quot;Posture Selection strategy: UNIFORM_RANDOM &quot;</span> &lt;&lt; endl;
        <span class="keywordflow">return</span> <span class="keyword">true</span>;
    }

    <a class="code" href="a00142.html#a626ad8d08de1e3d7fad2c8032f199933" title="The requested strategy for posture selection. To be given through configuration file.">postureSelStrategy</a> = MARKOV_BASE;

    <span class="comment">// make an empty matrix for the Markov Chain</span>
    <span class="keywordtype">double</span>** matrix = <span class="keyword">new</span> <span class="keywordtype">double</span>* [<a class="code" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f" title="Number of predefined postures.">numPostures</a>];
    <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0;i&lt;<a class="code" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f" title="Number of predefined postures.">numPostures</a>;++i)
        matrix[i] = <span class="keyword">new</span> <span class="keywordtype">double</span> [numPostures];

    <span class="keywordtype">bool</span> setDefault=<span class="keyword">false</span>; <span class="comment">// variable to remember if the default matrix is defined.</span>
    cXMLElementList::const_iterator matrixTag;
    <span class="keywordflow">for</span> (matrixTag = matrixList.begin(); matrixTag != matrixList.end(); matrixTag++)
    {

        cXMLElementList rowList;
        cXMLElementList cellList;
        <span class="keywordtype">int</span> i=0,j=0;
        <span class="keywordtype">bool</span> thisDefault = <span class="keyword">false</span>;

        <span class="keywordflow">if</span> ((*matrixTag)-&gt;getAttribute(<span class="stringliteral">&quot;type&quot;</span>) != NULL)
        {
            sstr = (*matrixTag)-&gt;getAttribute(<span class="stringliteral">&quot;type&quot;</span>);
            <span class="keywordflow">if</span> (sstr == <span class="stringliteral">&quot;Default&quot;</span> || sstr == <span class="stringliteral">&quot;default&quot;</span>)
            {
                <span class="keywordflow">if</span> (setDefault)
                    error (<span class="stringliteral">&quot;There are more than one default matrix defined in the configuration file!&quot;</span>);
                <span class="keywordflow">else</span>
                    {setDefault = <span class="keyword">true</span>; thisDefault = <span class="keyword">true</span>;}
            }
        }


        sstr = (*matrixTag)-&gt;getAttribute(<span class="stringliteral">&quot;name&quot;</span>);

        rowList = (*matrixTag)-&gt;getElementsByTagName(<span class="stringliteral">&quot;row&quot;</span>);
        <span class="keywordflow">if</span> (rowList.size()!= numPostures &amp;&amp; rowList.size()!= 1)
            error(<span class="stringliteral">&quot;Number of rows in  the Markov transition matrix should be equal to either the number&quot;</span>
                    <span class="stringliteral">&quot; of postures (full Markov matrix) or one (steady state vector)&quot;</span>);

        <span class="keywordflow">if</span> (rowList.size()!= numPostures &amp;&amp; thisDefault)
            error(<span class="stringliteral">&quot;Dimension of the default Markov matrix should be equal to the number of postures in the configuration file&quot;</span>);

        <span class="keywordflow">if</span> ((rowList.size()== 1) &amp;&amp; (!setDefault))
            error(<span class="stringliteral">&quot;A default matrix is supposed to be defined before a steady state can be defined in the configuration file&quot;</span>);

        <span class="keywordflow">for</span> (cXMLElementList::const_iterator row = rowList.begin(); row != rowList.end(); row++)
        {
            cellList = (*row)-&gt;getElementsByTagName(<span class="stringliteral">&quot;cell&quot;</span>);
            <span class="keywordflow">if</span> (cellList.size()!= <a class="code" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f" title="Number of predefined postures.">numPostures</a>)
                error(<span class="stringliteral">&quot;Number of columns in  the Markov transition matrix should be equal to the number of postures&quot;</span>);

            j=0;
            <span class="keywordflow">for</span> (cXMLElementList::const_iterator cell = cellList.begin(); cell != cellList.end(); cell++)
            {
                str = (*cell)-&gt;getAttribute(<span class="stringliteral">&quot;value&quot;</span>);
                matrix[i][j] = strtod(str, 0);
                j++;
            }

            ++i;
        }

        <span class="keywordflow">if</span> (rowList.size() == 1)
            <a class="code" href="a00142.html#a51f9fc44b5168e7ef6e58fd221bf3f0a" title="Class for performing operation for spatial and temporal correlations in posture selection.">transitions</a>-&gt;<a class="code" href="a00179.html#ac5c424a8372a3d6f39ccc06c88d4249f" title="Receives a steady state vector, extracts the corresponding transition matrix considering the default ...">addSteadyState</a>(sstr, matrix[0]); <span class="comment">// steady state</span>
        <span class="keywordflow">else</span>
            <a class="code" href="a00142.html#a51f9fc44b5168e7ef6e58fd221bf3f0a" title="Class for performing operation for spatial and temporal correlations in posture selection.">transitions</a>-&gt;<a class="code" href="a00179.html#a10abfb612543bbc52f6a13a0e138d822" title="Adds two matrices with dimension numPos*numPose .">addMatrix</a>(sstr, matrix, thisDefault);         <span class="comment">// A full Markovian matrix</span>

        EV &lt;&lt; <span class="stringliteral">&quot;Markov transition matrix &quot;</span> &lt;&lt; sstr &lt;&lt; <span class="stringliteral">&quot; : &quot;</span> &lt;&lt; endl;
        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k=0;k &lt; i ; ++k)
        {
            <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> f=0; f&lt;<a class="code" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f" title="Number of predefined postures.">numPostures</a> ;++f)
                EV &lt;&lt; matrix[k][f] &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;
            EV &lt;&lt; endl;
        }

    }

    <span class="comment">/* Reading the Area types, if there are any. */</span>
    tagList = xmlConfig-&gt;getElementsByTagName(<span class="stringliteral">&quot;areaTypes&quot;</span>);

    <span class="keywordflow">if</span> (tagList.empty())
        EV &lt;&lt; <span class="stringliteral">&quot;No area type is given. So there is no spatial correlation in posture selection.&quot;</span> &lt;&lt; endl;
    <span class="keywordflow">else</span> {

            tempTag = tagList.front();
            cXMLElementList typeList = tempTag-&gt;getElementsByTagName(<span class="stringliteral">&quot;areaType&quot;</span>);

            <span class="keywordflow">if</span> (typeList.empty())
                error (<span class="stringliteral">&quot;No areaType has been defined in areaTypes!&quot;</span>);

            <span class="keywordflow">for</span> (cXMLElementList::const_iterator aType = typeList.begin(); aType != typeList.end(); aType++)
            {
                sstr = (*aType)-&gt;getAttribute(<span class="stringliteral">&quot;name&quot;</span>);

                EV &lt;&lt; <span class="stringliteral">&quot;Area type &quot;</span> &lt;&lt; sstr &lt;&lt; <span class="stringliteral">&quot; : &quot;</span> &lt;&lt; endl;

                <span class="keywordtype">int</span> typeID = <a class="code" href="a00142.html#a51f9fc44b5168e7ef6e58fd221bf3f0a" title="Class for performing operation for spatial and temporal correlations in posture selection.">transitions</a>-&gt;<a class="code" href="a00179.html#a261ad915b2a9c7cdf7082660360190e4" title="Adds a area type to the list with the given name and returns the index of this area type in the list...">addAreaType</a>(sstr);

                cXMLElementList boundList = (*aType)-&gt;getElementsByTagName(<span class="stringliteral">&quot;boundary&quot;</span>);
                <span class="keywordflow">if</span> (boundList.empty())
                    error (<span class="stringliteral">&quot;No boundary is given for a area type!&quot;</span>);

                <a class="code" href="a00065.html" title="Class for storing 3D coordinates.">Coord</a> minBound, maxBound;
                <span class="keywordflow">for</span> (cXMLElementList::const_iterator aBound = boundList.begin(); aBound != boundList.end(); aBound++)
                {
                    str = (*aBound)-&gt;getAttribute(<span class="stringliteral">&quot;xMin&quot;</span>); minBound.x = strtod(str, 0);
                    str = (*aBound)-&gt;getAttribute(<span class="stringliteral">&quot;yMin&quot;</span>); minBound.y = strtod(str, 0);
                    str = (*aBound)-&gt;getAttribute(<span class="stringliteral">&quot;zMin&quot;</span>); minBound.z = strtod(str, 0);

                    str = (*aBound)-&gt;getAttribute(<span class="stringliteral">&quot;xMax&quot;</span>); maxBound.x = strtod(str, 0);
                    str = (*aBound)-&gt;getAttribute(<span class="stringliteral">&quot;yMax&quot;</span>); maxBound.y = strtod(str, 0);
                    str = (*aBound)-&gt;getAttribute(<span class="stringliteral">&quot;zMax&quot;</span>); maxBound.z = strtod(str, 0);

                    <a class="code" href="a00142.html#a51f9fc44b5168e7ef6e58fd221bf3f0a" title="Class for performing operation for spatial and temporal correlations in posture selection.">transitions</a>-&gt;<a class="code" href="a00179.html#a309ed6acf7eca6469f0ea0f06ee41780" title="Adds the given boundary to the existing area type specified by the given ID .">setAreaBoundry</a>(typeID,minBound,maxBound);
                    EV &lt;&lt; <span class="stringliteral">&quot;Low bound: &quot;</span> &lt;&lt; minBound.<a class="code" href="a00065.html#a86994bfa7096155d951abb03dcf30bf1" title="Returns a string with the value of the coordinate.">info</a>() &lt;&lt; endl;
                    EV &lt;&lt; <span class="stringliteral">&quot;High bound: &quot;</span> &lt;&lt; maxBound.<a class="code" href="a00065.html#a86994bfa7096155d951abb03dcf30bf1" title="Returns a string with the value of the coordinate.">info</a>() &lt;&lt; endl;
                }
            }
        }

    <span class="comment">/* Reading the time domains, if there are any. */</span>
    tagList = xmlConfig-&gt;getElementsByTagName(<span class="stringliteral">&quot;timeDomains&quot;</span>);

    <span class="keywordflow">if</span> (tagList.empty())
        EV &lt;&lt; <span class="stringliteral">&quot;No time domain is given. So there is no temporal correlation in posture selection.&quot;</span> &lt;&lt; endl;
    <span class="keywordflow">else</span> {

            tempTag = tagList.front();
            cXMLElementList typeList = tempTag-&gt;getElementsByTagName(<span class="stringliteral">&quot;timeDomain&quot;</span>);

            <span class="keywordflow">if</span> (typeList.empty())
                error (<span class="stringliteral">&quot;No timeDomain has been defined in timeDomains!&quot;</span>);

            <span class="keywordflow">for</span> (cXMLElementList::const_iterator aType = typeList.begin(); aType != typeList.end(); aType++)
            {
                sstr = (*aType)-&gt;getAttribute(<span class="stringliteral">&quot;name&quot;</span>);

                EV &lt;&lt; <span class="stringliteral">&quot;Time domain &quot;</span> &lt;&lt; sstr &lt;&lt; <span class="stringliteral">&quot; : &quot;</span> &lt;&lt; endl;

                <span class="keywordtype">int</span> typeID = <a class="code" href="a00142.html#a51f9fc44b5168e7ef6e58fd221bf3f0a" title="Class for performing operation for spatial and temporal correlations in posture selection.">transitions</a>-&gt;<a class="code" href="a00179.html#a58c7924dfb8810ba37311217a7ba5c8d" title="Adds a time domain to the list with the given name and returns the index of the this time domain in t...">addTimeDomain</a>(sstr);

                cXMLElementList boundList = (*aType)-&gt;getElementsByTagName(<span class="stringliteral">&quot;boundary&quot;</span>);
                <span class="keywordflow">if</span> (boundList.empty())
                    error (<span class="stringliteral">&quot;No boundary is given for a time domain!&quot;</span>);

                simtime_t minTime,maxTime;
                <span class="keywordflow">for</span> (cXMLElementList::const_iterator aBound = boundList.begin(); aBound != boundList.end(); aBound++)
                {
                    str = (*aBound)-&gt;getAttribute(<span class="stringliteral">&quot;tMin&quot;</span>); minTime = strtod(str,0);
                    str = (*aBound)-&gt;getAttribute(<span class="stringliteral">&quot;tMax&quot;</span>); maxTime = strtod(str,0);

                    <a class="code" href="a00142.html#a51f9fc44b5168e7ef6e58fd221bf3f0a" title="Class for performing operation for spatial and temporal correlations in posture selection.">transitions</a>-&gt;<a class="code" href="a00179.html#af66d8f9dda835d55dc3009cf582f87d8" title="Adds the given boundary to the existing time domain specified by the given ID .">setTimeBoundry</a>(typeID,minTime,maxTime);
                    EV &lt;&lt; <span class="stringliteral">&quot;Low bound: (&quot;</span> &lt;&lt; minTime.dbl() &lt;&lt; <span class="stringliteral">&quot;, &quot;</span> &lt;&lt; maxTime &lt;&lt; <span class="stringliteral">&quot;)&quot;</span> &lt;&lt; endl;
                }
            }
    }

    <span class="comment">/* Reading the combinations, if there are any. */</span>
    tagList = xmlConfig-&gt;getElementsByTagName(<span class="stringliteral">&quot;combinations&quot;</span>);

    <span class="keywordflow">if</span> (tagList.empty())
        EV &lt;&lt; <span class="stringliteral">&quot;No combination is given. The default Markov model is then used for the whole time and space!&quot;</span> &lt;&lt; endl;
    <span class="keywordflow">else</span> {
            tempTag = tagList.front();
            cXMLElementList combList = tempTag-&gt;getElementsByTagName(<span class="stringliteral">&quot;combination&quot;</span>);

            <span class="keywordflow">if</span> (combList.empty())
                error (<span class="stringliteral">&quot;No combination has been defined in combinations!&quot;</span>);

            EV &lt;&lt; <span class="stringliteral">&quot;Combinations: &quot;</span> &lt;&lt; endl;

            <span class="keywordflow">for</span> (cXMLElementList::const_iterator aComb = combList.begin(); aComb != combList.end(); aComb++)
            {
                std::string areaName,timeName,matrixName;

                <span class="keywordflow">if</span> ((*aComb)-&gt;getAttribute(<span class="stringliteral">&quot;areaType&quot;</span>) != NULL)
                    areaName = (*aComb)-&gt;getAttribute(<span class="stringliteral">&quot;areaType&quot;</span>);
                <span class="keywordflow">else</span>
                    areaName.clear();

                <span class="keywordflow">if</span> ((*aComb)-&gt;getAttribute(<span class="stringliteral">&quot;timeDomain&quot;</span>) != NULL)
                    timeName = (*aComb)-&gt;getAttribute(<span class="stringliteral">&quot;timeDomain&quot;</span>);
                <span class="keywordflow">else</span>
                    timeName.clear();

                <span class="keywordflow">if</span> ((*aComb)-&gt;getAttribute(<span class="stringliteral">&quot;matrix&quot;</span>) != NULL)
                    matrixName = (*aComb)-&gt;getAttribute(<span class="stringliteral">&quot;matrix&quot;</span>);
                <span class="keywordflow">else</span>
                    error(<span class="stringliteral">&quot;No transition matrix is specified for a combination&quot;</span>);

                <a class="code" href="a00142.html#a51f9fc44b5168e7ef6e58fd221bf3f0a" title="Class for performing operation for spatial and temporal correlations in posture selection.">transitions</a>-&gt;<a class="code" href="a00179.html#a5b4ab00961c0039aac63143d28e88272" title="Adds a space-time combination to the list.">addCombination</a>(areaName, timeName, matrixName);

                EV &lt;&lt; <span class="stringliteral">&quot;(&quot;</span> &lt;&lt; areaName &lt;&lt; <span class="stringliteral">&quot;, &quot;</span> &lt;&lt; timeName &lt;&lt; <span class="stringliteral">&quot;, &quot;</span> &lt;&lt; matrixName &lt;&lt; <span class="stringliteral">&quot;)&quot;</span> &lt;&lt; endl;
            }
        }

    <span class="keywordflow">return</span> <span class="keyword">true</span>;
}
</pre></div>
</div>
</div>
<a class="anchor" id="a31810405333b184c9db891fa9bd8a12a"></a><!-- doxytag: member="MoBANCoordinator::readMobilityPatternFile" ref="a31810405333b184c9db891fa9bd8a12a" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool MoBANCoordinator::readMobilityPatternFile </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Reads the previously logged mobility pattern and make mobility pattern data base. </p>
<p>This function reads the input mobility pattern file and make a list of the mobility patterns. It will be called in the initialization phase if the useMobilityPattern parameter is true. </p>

<p>References <a class="el" href="a00142.html#aeff87bd9af8cb9aa14eada4b73ec4fbe">currentPattern</a>, <a class="el" href="a00142.html#ae19a9a2dce220a75c4757381b5f348a7">mobilityPattern</a>, <a class="el" href="a00142.html#a00cbcb40ee4039ffd5723ffa4334d88f">patternLength</a>, and <a class="el" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5">postureList</a>.</p>

<p>Referenced by <a class="el" href="a00142.html#a9e116be526a0d4f1f4482728f32c237c">initialize()</a>.</p>
<div class="fragment"><pre class="fragment">                                               {
    <a class="code" href="a00142.html#a00cbcb40ee4039ffd5723ffa4334d88f" title="The number of mobility pattern instances which has been read from the input file (length of mobility ...">patternLength</a> = 0;
    <span class="keywordtype">double</span> x, y, z, s;
    <span class="keywordtype">int</span> id;
    <span class="keywordtype">char</span> file_name[70];
    <span class="keywordtype">char</span> posture_name[50];

    sprintf(file_name, <span class="stringliteral">&quot;%s&quot;</span>, par(<span class="stringliteral">&quot;mobilityPatternFile&quot;</span>).stringValue());
    FILE *fp = fopen(file_name, <span class="stringliteral">&quot;r&quot;</span>);
    <span class="keywordflow">if</span> (fp == NULL)
        <span class="keywordflow">return</span> <span class="keyword">false</span>;

    <span class="comment">// count number of patterns (lines in the input file)</span>
    <span class="keywordtype">int</span> c;
    <span class="keywordflow">while</span> ((c = fgetc(fp)) != EOF)
        <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;\n&#39;</span>)
            <a class="code" href="a00142.html#a00cbcb40ee4039ffd5723ffa4334d88f" title="The number of mobility pattern instances which has been read from the input file (length of mobility ...">patternLength</a>++;
    fclose(fp);

    EV &lt;&lt; <span class="stringliteral">&quot;Mobility Pattern Length: &quot;</span> &lt;&lt; <a class="code" href="a00142.html#a00cbcb40ee4039ffd5723ffa4334d88f" title="The number of mobility pattern instances which has been read from the input file (length of mobility ...">patternLength</a> &lt;&lt; endl;

    <a class="code" href="a00142.html#ae19a9a2dce220a75c4757381b5f348a7" title="The mobility pattern data base.">mobilityPattern</a> = <span class="keyword">new</span> <a class="code" href="a00142.html#aba7c0480967381f3cb5c09b05029abe7" title="Data type for one instance of mobility pattern.">Pattern</a>[<a class="code" href="a00142.html#a00cbcb40ee4039ffd5723ffa4334d88f" title="The number of mobility pattern instances which has been read from the input file (length of mobility ...">patternLength</a>];

    fp = fopen(file_name,<span class="stringliteral">&quot;r&quot;</span>);

    <span class="keywordtype">int</span> i=0;
    <span class="keywordflow">while</span> (fscanf(fp,<span class="stringliteral">&quot;%s %d&quot;</span>,posture_name,&amp;<span class="keywordtype">id</span>)!= -1) {
        <a class="code" href="a00142.html#ae19a9a2dce220a75c4757381b5f348a7" title="The mobility pattern data base.">mobilityPattern</a>[i].postureID = id;
        <span class="keywordflow">if</span> (<a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[<span class="keywordtype">id</span>]-&gt;isMobile())
        {
            assert(fscanf(fp,<span class="stringliteral">&quot;%le %le %le %le&quot;</span>,&amp;x,&amp;y,&amp;z,&amp;s)!=-1);
            <a class="code" href="a00142.html#ae19a9a2dce220a75c4757381b5f348a7" title="The mobility pattern data base.">mobilityPattern</a>[i].targetPos = <a class="code" href="a00065.html" title="Class for storing 3D coordinates.">Coord</a>(x,y,z);
            <a class="code" href="a00142.html#ae19a9a2dce220a75c4757381b5f348a7" title="The mobility pattern data base.">mobilityPattern</a>[i].speed = s;
        }
        <span class="keywordflow">else</span>
        {
            assert (fscanf(fp,<span class="stringliteral">&quot;%le&quot;</span>,&amp;x)!=-1);
            <a class="code" href="a00142.html#ae19a9a2dce220a75c4757381b5f348a7" title="The mobility pattern data base.">mobilityPattern</a>[i].duration = x;
        }
        ++i;
    }

    fclose(fp);

    <a class="code" href="a00142.html#aeff87bd9af8cb9aa14eada4b73ec4fbe" title="The index of the currently applied mobility pattern from.">currentPattern</a> = -1;

    <span class="keywordflow">return</span> <span class="keyword">true</span>;
}
</pre></div>
</div>
</div>
<a class="anchor" id="aab85ba2010884afd66f619718e1194d7"></a><!-- doxytag: member="MoBANCoordinator::readPostureSpecificationFile" ref="aab85ba2010884afd66f619718e1194d7" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool MoBANCoordinator::readPostureSpecificationFile </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Reading the input postures specification file and making the posture data base. </p>
<p>Function to read the specified posture specification input file and make the posture data base. The posture specification includes the specification of a set of possible body postures in the target application. The specification of each posture should provide the speed range of the global movement of the whole WBAN and the relative position of the reference point, movement radius around the reference point and movement velocity of all nodes in the WBAN. The function will be called in the initialization phase. </p>

<p>References <a class="el" href="a00142.html#a357c9f724ee27d0c33a1543e650b9e48">localModules</a>, <a class="el" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f">numPostures</a>, and <a class="el" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5">postureList</a>.</p>

<p>Referenced by <a class="el" href="a00142.html#a9e116be526a0d4f1f4482728f32c237c">initialize()</a>.</p>
<div class="fragment"><pre class="fragment">                                                    {

    cXMLElement* xmlPosture = par(<span class="stringliteral">&quot;postureSpecFile&quot;</span>).xmlValue();
    <span class="keywordflow">if</span> (xmlPosture == 0)
        <span class="keywordflow">return</span> <span class="keyword">false</span>;

    <span class="keyword">const</span> <span class="keywordtype">char</span>* str;

    <span class="comment">// read the specification of every posture from file and make a list of postures</span>
    cXMLElementList postures;

    postures = xmlPosture-&gt;getElementsByTagName(<span class="stringliteral">&quot;posture&quot;</span>);

    <span class="comment">// find the number of defined postures</span>
    <a class="code" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f" title="Number of predefined postures.">numPostures</a> = postures.size();
    <span class="keywordflow">if</span> (<a class="code" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f" title="Number of predefined postures.">numPostures</a> == 0)
        error(<span class="stringliteral">&quot;No posture is defined in the input posture specification file&quot;</span>);

    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> postureID;

    cXMLElementList::const_iterator posture;
    <span class="keywordflow">for</span> (posture = postures.begin(); posture != postures.end(); posture++)
    {
        str = (*posture)-&gt;getAttribute(<span class="stringliteral">&quot;postureID&quot;</span>);
        postureID = strtol(str, 0, 0);
        <span class="keywordflow">if</span> (postureID &lt; 0 || postureID &gt;= <a class="code" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f" title="Number of predefined postures.">numPostures</a>)
            error (<span class="stringliteral">&quot;Posture ID in input posture specification file is out of the range&quot;</span>);

        <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>.push_back(<span class="keyword">new</span> <a class="code" href="a00178.html" title="to store the specification of a posture on the MoBAN mobility model.">Posture</a>(postureID, <a class="code" href="a00142.html#a357c9f724ee27d0c33a1543e650b9e48" title="The mobility modules of the nodes in this WBAN.">localModules</a>.size()));

        str = (*posture)-&gt;getAttribute(<span class="stringliteral">&quot;name&quot;</span>);
        <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[postureID]-&gt;setPostureName(const_cast&lt;char*&gt; (str));

        str = (*posture)-&gt;getAttribute(<span class="stringliteral">&quot;minSpeed&quot;</span>);
        <span class="keywordtype">double</span> minS = strtod(str, 0);
        str = (*posture)-&gt;getAttribute(<span class="stringliteral">&quot;maxSpeed&quot;</span>);
        <span class="keywordtype">double</span> maxS = strtod(str, 0);
        <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[postureID]-&gt;setPostureSpeed(minS, maxS);

        <span class="keywordtype">int</span> i = 0;
        <span class="keywordtype">double</span> x, y, z, s, r;
        cXMLElementList nodeParameters;

        nodeParameters = (*posture)-&gt;getElementsByTagName(<span class="stringliteral">&quot;nodeParameters&quot;</span>);
        <span class="keywordflow">if</span> (nodeParameters.size() != <a class="code" href="a00142.html#a357c9f724ee27d0c33a1543e650b9e48" title="The mobility modules of the nodes in this WBAN.">localModules</a>.size())
            error (<span class="stringliteral">&quot;Some nodes may not have specified parameters in a posture in input posture specification file&quot;</span>);

        cXMLElementList::const_iterator param;
        <span class="keywordflow">for</span> (param = nodeParameters.begin(); param!= nodeParameters.end(); param++)
        {
            str = (*param)-&gt;getAttribute(<span class="stringliteral">&quot;positionX&quot;</span>);
            x = strtod(str, 0);

            str = (*param)-&gt;getAttribute(<span class="stringliteral">&quot;positionY&quot;</span>);
            y = strtod(str, 0);

            str = (*param)-&gt;getAttribute(<span class="stringliteral">&quot;positionZ&quot;</span>);
            z = strtod(str, 0);

            str = (*param)-&gt;getAttribute(<span class="stringliteral">&quot;radius&quot;</span>);
            r = strtod(str, 0);

            str = (*param)-&gt;getAttribute(<span class="stringliteral">&quot;speed&quot;</span>);
            s = strtod(str, 0);

            <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[postureID]-&gt;setPs(i, <a class="code" href="a00065.html" title="Class for storing 3D coordinates.">Coord</a>(x, y, z));
            <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[postureID]-&gt;setRadius(i, r);
            <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[postureID]-&gt;setSpeed(i, s);

            i++;
        }
    }

    <span class="comment">/* Report the obtained specification of the postures. */</span>
    <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f" title="Number of predefined postures.">numPostures</a>; ++i) {
        EV &lt;&lt; <span class="stringliteral">&quot;Information for the posture: &quot;</span> &lt;&lt; i &lt;&lt; <span class="stringliteral">&quot; is&quot;</span> &lt;&lt; endl;
        <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0; j &lt; <a class="code" href="a00142.html#a357c9f724ee27d0c33a1543e650b9e48" title="The mobility modules of the nodes in this WBAN.">localModules</a>.size(); ++j)
        EV &lt;&lt; <span class="stringliteral">&quot;Node &quot;</span> &lt;&lt; j &lt;&lt; <span class="stringliteral">&quot; position: &quot;</span> &lt;&lt; <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[i]-&gt;getPs(j).info() &lt;&lt;
            <span class="stringliteral">&quot; and radius: &quot;</span> &lt;&lt; <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[i]-&gt;getRadius(j) &lt;&lt; <span class="stringliteral">&quot; and speed: &quot;</span> &lt;&lt; <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[i]-&gt;getSpeed(j) &lt;&lt; endl;
    }

    <span class="keywordflow">return</span> <span class="keyword">true</span>;

}
</pre></div>
</div>
</div>
<a class="anchor" id="adebee0a447b7e85d444054fa3a4ee013"></a><!-- doxytag: member="MoBANCoordinator::selectDestination" ref="adebee0a447b7e85d444054fa3a4ee013" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00065.html">Coord</a> MoBANCoordinator::selectDestination </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Function to select the destination in the case of a mobile posture. </p>
<p>Select a position inside the simulation area as the destination for the new mobile posture. It is called whenever a new mobile posture is selected. It is taken into account that all nodes should be inside the area. </p>

<p>References <a class="el" href="a00145.html#a07eac3b0d197edaa3e9509e80ae21af1">MobilityBase::getRandomPosition()</a>, <a class="el" href="a00142.html#aa9e9424cb4572715a8f5b042aa4155d0">isInsideWorld()</a>, and <a class="el" href="a00145.html#a82ae637969433a492154b26039b84038">MobilityBase::lastPosition</a>.</p>

<p>Referenced by <a class="el" href="a00142.html#ae4a1b3a24c63d32ff44a92d58633ce06">initializePosition()</a>, and <a class="el" href="a00142.html#a9f2559857f8062a663d8672187a18a1a">setTargetPosition()</a>.</p>
<div class="fragment"><pre class="fragment">                                          {
    <a class="code" href="a00065.html" title="Class for storing 3D coordinates.">Coord</a> res;
    res = <a class="code" href="a00145.html#a07eac3b0d197edaa3e9509e80ae21af1" title="Returns a new random position satisfying the constraint area.">getRandomPosition</a>();
    res.z = <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.z; <span class="comment">// the z value remain the same</span>

    <span class="comment">// check if it is okay using CoverRadius</span>
    <span class="keywordflow">while</span> (!<a class="code" href="a00142.html#aa9e9424cb4572715a8f5b042aa4155d0" title="Checks if all nodes of the WBAN are inside the simulation environment with the given position of the ...">isInsideWorld</a>(res)) {
        res = <a class="code" href="a00145.html#a07eac3b0d197edaa3e9509e80ae21af1" title="Returns a new random position satisfying the constraint area.">getRandomPosition</a>();
        res.z = <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.z;
    }

    <span class="keywordflow">return</span> res;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ab4f9d86a51c84b083817db1fcbe9dbab"></a><!-- doxytag: member="MoBANCoordinator::selectDuration" ref="ab4f9d86a51c84b083817db1fcbe9dbab" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">simtime_t MoBANCoordinator::selectDuration </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Select a stay time duration in the specified range for the new posture. </p>
<p>Select a stay time duration in the specified duration range for the new posture. It is called whenever a new stable posture is selected. </p>

<p>References <a class="el" href="a00142.html#a02c4e8d23a6b0b2e1a1d94abe1974b9f">maxDuration</a>, and <a class="el" href="a00142.html#aac48e46d43458a8f960cc33e84ac85e8">minDuration</a>.</p>

<p>Referenced by <a class="el" href="a00142.html#a9f2559857f8062a663d8672187a18a1a">setTargetPosition()</a>.</p>
<div class="fragment"><pre class="fragment">                                           {
    <span class="keywordflow">return</span> uniform(<a class="code" href="a00142.html#aac48e46d43458a8f960cc33e84ac85e8" title="The minimum value of the duration for stable postures.">minDuration</a>, <a class="code" href="a00142.html#a02c4e8d23a6b0b2e1a1d94abe1974b9f" title="The maximum value of the duration for stable postures.">maxDuration</a>);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ab622d4b167d9d5dbc7529969a6688597"></a><!-- doxytag: member="MoBANCoordinator::selectPosture" ref="ab622d4b167d9d5dbc7529969a6688597" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MoBANCoordinator::selectPosture </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Function to select the next posture considering the current posture and the Markov model. </p>
<p>Select a new posture randomly or based on the given Markov model. If the requested strategy is not uniform random, A Markov chain will be used. If the strategy is INDIVIDUAL_MARKOV, we should retrieve the transition matrix for the current part of the area. If it is INDIVIDUAL_MARKOV, we have the base transition matrix and a steady state vector for the current part of the area. So the closest transition matrix to the base matrix is calculated which satisfies the required steady state vector. In any case, the next posture is selected considering the current posture and according to the final Markov transition matrix. </p>

<p>References <a class="el" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46">currentPosture</a>, <a class="el" href="a00179.html#a1f04b24b643026f15fbc95d175429c5f">PostureTransition::getMatrix()</a>, <a class="el" href="a00178.html#a217bc7334d61b9441c06affd81798445">Posture::getPostureID()</a>, <a class="el" href="a00145.html#a82ae637969433a492154b26039b84038">MobilityBase::lastPosition</a>, <a class="el" href="a00142.html#a406987de5c4e38c461e0857583c115b2">markovMatrix</a>, <a class="el" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f">numPostures</a>, <a class="el" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5">postureList</a>, <a class="el" href="a00142.html#a626ad8d08de1e3d7fad2c8032f199933">postureSelStrategy</a>, and <a class="el" href="a00142.html#a51f9fc44b5168e7ef6e58fd221bf3f0a">transitions</a>.</p>

<p>Referenced by <a class="el" href="a00142.html#a9f2559857f8062a663d8672187a18a1a">setTargetPosition()</a>.</p>
<div class="fragment"><pre class="fragment">                                     {
    <span class="keywordtype">int</span> postureID;

    <span class="keywordflow">if</span> (<a class="code" href="a00142.html#a626ad8d08de1e3d7fad2c8032f199933" title="The requested strategy for posture selection. To be given through configuration file.">postureSelStrategy</a> == UNIFORM_RANDOM) {
        postureID = floor(uniform(0, <a class="code" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f" title="Number of predefined postures.">numPostures</a>)); <span class="comment">// uniformly random posture selection</span>
        <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a> = <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[postureID];
        <span class="keywordflow">return</span>;
    }

    <span class="comment">/* Here we check the area and the time to determine the corresponding posture transition matrix */</span>
    <a class="code" href="a00142.html#a406987de5c4e38c461e0857583c115b2" title="A matrix which maintains the transition probabilities of the Markov Model of posture pattern...">markovMatrix</a> = <a class="code" href="a00142.html#a51f9fc44b5168e7ef6e58fd221bf3f0a" title="Class for performing operation for spatial and temporal correlations in posture selection.">transitions</a>-&gt;<a class="code" href="a00179.html#a1f04b24b643026f15fbc95d175429c5f" title="Gets a time and location, and returns the corresponding Markov transition matrix.">getMatrix</a>(simTime(), <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>);

    <span class="comment">/* Using transition matrix to select the next posture */</span>
    <span class="keywordtype">double</span> randomValue = uniform(0, 1);
    <span class="keywordtype">double</span> comp = 0;
    <span class="keywordtype">int</span> currentP = <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a217bc7334d61b9441c06affd81798445" title="Returns the unique Id (index) of this posture.">getPostureID</a>(); <span class="comment">// it determines the column in the matrix</span>

    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; static_cast&lt;int&gt;(<a class="code" href="a00142.html#a3880f0e3e0e489b1edd2692a441b903f" title="Number of predefined postures.">numPostures</a>); ++i)
    {
        comp += <a class="code" href="a00142.html#a406987de5c4e38c461e0857583c115b2" title="A matrix which maintains the transition probabilities of the Markov Model of posture pattern...">markovMatrix</a>[i][currentP];
        <span class="keywordflow">if</span> (randomValue &lt; comp)
        {
            postureID = i;
            <span class="keywordflow">break</span>;
        }
    }

    <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a> = <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[postureID];
}
</pre></div>
</div>
</div>
<a class="anchor" id="a6d83b8c03d91b0fee3e335b214f51b4c"></a><!-- doxytag: member="MoBANCoordinator::selectSpeed" ref="a6d83b8c03d91b0fee3e335b214f51b4c" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">double MoBANCoordinator::selectSpeed </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Select a velocity value within the given velocity range. </p>
<p>Select a velocity value within the given velocity range. It is called whenever a new stable posture is selected. In the case of using a logged mobility pattern, the speed value is retrieved from the pattern. </p>

<p>References <a class="el" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46">currentPosture</a>, <a class="el" href="a00178.html#a99d879a60f411811fad6949c3b7811a3">Posture::getMaxSpeed()</a>, and <a class="el" href="a00178.html#ac805f463e2f12178b128f741cfc2f8ec">Posture::getMinSpeed()</a>.</p>

<p>Referenced by <a class="el" href="a00142.html#a9f2559857f8062a663d8672187a18a1a">setTargetPosition()</a>.</p>
<div class="fragment"><pre class="fragment">                                     {
    <span class="keywordflow">return</span> (uniform(<a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#ac805f463e2f12178b128f741cfc2f8ec" title="Returns minimum value of the speed range of this posture.">getMinSpeed</a>(), <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a99d879a60f411811fad6949c3b7811a3" title="Returns maximum value of the speed range of this posture.">getMaxSpeed</a>()));
}
</pre></div>
</div>
</div>
<a class="anchor" id="a9f2559857f8062a663d8672187a18a1a"></a><!-- doxytag: member="MoBANCoordinator::setTargetPosition" ref="a9f2559857f8062a663d8672187a18a1a" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MoBANCoordinator::setTargetPosition </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Set a new target position from the next posture. </p>
<p>The main process of the MoBAN mobility model. To be called whenever a destination is reached or the duration of the previous posture expires. It select the behavior of the next movement (the posture and the destination), and prepare the required variables to make the movement. In the case of using a logged mobility pattern, the new posture and other parameters are obtained from the pattern. </p>

<p>Implements <a class="el" href="a00124.html#ae9b65139861752e826e50eb23cd5a470">LineSegmentsMobilityBase</a>.</p>

<p>References <a class="el" href="a00142.html#aeff87bd9af8cb9aa14eada4b73ec4fbe">currentPattern</a>, <a class="el" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46">currentPosture</a>, <a class="el" href="a00065.html#ab6a7bfcc5c55e5d8edbc7c0cb5a11626">Coord::distance()</a>, <a class="el" href="a00178.html#a217bc7334d61b9441c06affd81798445">Posture::getPostureID()</a>, <a class="el" href="a00178.html#a40dc6d7007b14e779420da389e927aec">Posture::getPostureName()</a>, <a class="el" href="a00065.html#a86994bfa7096155d951abb03dcf30bf1">Coord::info()</a>, <a class="el" href="a00178.html#a7057d6de18f8fd8d646e0d370ab8c2a5">Posture::isMobile()</a>, <a class="el" href="a00145.html#a82ae637969433a492154b26039b84038">MobilityBase::lastPosition</a>, <a class="el" href="a00142.html#abb700aed062784b7cb21eec3e146c80d">logfile</a>, <a class="el" href="a00142.html#ae19a9a2dce220a75c4757381b5f348a7">mobilityPattern</a>, <a class="el" href="a00147.html#a5c6e51e3ac03c935482057ce7726eb3d">MovingMobilityBase::nextChange</a>, <a class="el" href="a00142.html#a00cbcb40ee4039ffd5723ffa4334d88f">patternLength</a>, <a class="el" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5">postureList</a>, <a class="el" href="a00142.html#a7e5b78357b30b23f2f8285dcde5c6dd9">publishToNodes()</a>, <a class="el" href="a00142.html#adebee0a447b7e85d444054fa3a4ee013">selectDestination()</a>, <a class="el" href="a00142.html#ab4f9d86a51c84b083817db1fcbe9dbab">selectDuration()</a>, <a class="el" href="a00142.html#ab622d4b167d9d5dbc7529969a6688597">selectPosture()</a>, <a class="el" href="a00142.html#a6d83b8c03d91b0fee3e335b214f51b4c">selectSpeed()</a>, <a class="el" href="a00142.html#afdfb553fa2576a3e72a6111b12f14a97">speed</a>, <a class="el" href="a00124.html#acf4b064a5f64a5bc493e497c1cf134ac">LineSegmentsMobilityBase::targetPosition</a>, and <a class="el" href="a00142.html#a6f67cb3412735ec31734d8a345688e5b">useMobilityPattern</a>.</p>
<div class="fragment"><pre class="fragment">                                         {
    <span class="comment">// select the new posture and set the variable currentPosture as well as the reference points of all nodes within the WBAN.</span>
    <span class="keywordflow">if</span> (<a class="code" href="a00142.html#a6f67cb3412735ec31734d8a345688e5b" title="Variable that shows if reusing previously logged mobility pattern is requested. The value is gotten f...">useMobilityPattern</a>) {
        <a class="code" href="a00142.html#aeff87bd9af8cb9aa14eada4b73ec4fbe" title="The index of the currently applied mobility pattern from.">currentPattern</a> = (<a class="code" href="a00142.html#aeff87bd9af8cb9aa14eada4b73ec4fbe" title="The index of the currently applied mobility pattern from.">currentPattern</a> + 1) % <a class="code" href="a00142.html#a00cbcb40ee4039ffd5723ffa4334d88f" title="The number of mobility pattern instances which has been read from the input file (length of mobility ...">patternLength</a>;
        <span class="keywordtype">int</span> postureID = <a class="code" href="a00142.html#ae19a9a2dce220a75c4757381b5f348a7" title="The mobility pattern data base.">mobilityPattern</a>[<a class="code" href="a00142.html#aeff87bd9af8cb9aa14eada4b73ec4fbe" title="The index of the currently applied mobility pattern from.">currentPattern</a>].postureID;
        <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a> = <a class="code" href="a00142.html#afbb28bcb93bda1faadc7030d86be43b5" title="The list of all predefined postures (posture data base)">postureList</a>[postureID];
    } <span class="keywordflow">else</span>
        <a class="code" href="a00142.html#ab622d4b167d9d5dbc7529969a6688597" title="Function to select the next posture considering the current posture and the Markov model...">selectPosture</a>();

    EV &lt;&lt; <span class="stringliteral">&quot;New posture is selected: &quot;</span> &lt;&lt; <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a40dc6d7007b14e779420da389e927aec" title="Returns posture name.">getPostureName</a>() &lt;&lt; endl;

    simtime_t duration;
    <span class="keywordflow">if</span> (<a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a7057d6de18f8fd8d646e0d370ab8c2a5" title="Check if this posture is mobile by checking the maximum possible speed.">isMobile</a>())
    {
        <span class="keywordtype">double</span> distance;

        <span class="keywordflow">if</span> (<a class="code" href="a00142.html#a6f67cb3412735ec31734d8a345688e5b" title="Variable that shows if reusing previously logged mobility pattern is requested. The value is gotten f...">useMobilityPattern</a>) {
            <a class="code" href="a00124.html#acf4b064a5f64a5bc493e497c1cf134ac" title="End position of current linear movement.">targetPosition</a> = <a class="code" href="a00142.html#ae19a9a2dce220a75c4757381b5f348a7" title="The mobility pattern data base.">mobilityPattern</a>[<a class="code" href="a00142.html#aeff87bd9af8cb9aa14eada4b73ec4fbe" title="The index of the currently applied mobility pattern from.">currentPattern</a>].targetPos;
            <a class="code" href="a00142.html#afdfb553fa2576a3e72a6111b12f14a97" title="Currently selected speed for the mobile posture.">speed</a> = <a class="code" href="a00142.html#ae19a9a2dce220a75c4757381b5f348a7" title="The mobility pattern data base.">mobilityPattern</a>[<a class="code" href="a00142.html#aeff87bd9af8cb9aa14eada4b73ec4fbe" title="The index of the currently applied mobility pattern from.">currentPattern</a>].speed;
        }
        <span class="keywordflow">else</span> {
            <a class="code" href="a00124.html#acf4b064a5f64a5bc493e497c1cf134ac" title="End position of current linear movement.">targetPosition</a> = <a class="code" href="a00142.html#adebee0a447b7e85d444054fa3a4ee013" title="Function to select the destination in the case of a mobile posture.">selectDestination</a>();
            <a class="code" href="a00142.html#afdfb553fa2576a3e72a6111b12f14a97" title="Currently selected speed for the mobile posture.">speed</a> = <a class="code" href="a00142.html#a6d83b8c03d91b0fee3e335b214f51b4c" title="Select a velocity value within the given velocity range.">selectSpeed</a>();
        }

        <span class="keywordflow">if</span> (<a class="code" href="a00142.html#afdfb553fa2576a3e72a6111b12f14a97" title="Currently selected speed for the mobile posture.">speed</a>==0)
            error(<span class="stringliteral">&quot;The velocity in a mobile posture should not be zero!&quot;</span>);

        distance = <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.<a class="code" href="a00065.html#ab6a7bfcc5c55e5d8edbc7c0cb5a11626" title="Returns the distance to Coord &#39;a&#39;.">distance</a>(<a class="code" href="a00124.html#acf4b064a5f64a5bc493e497c1cf134ac" title="End position of current linear movement.">targetPosition</a>);
        duration = distance / <a class="code" href="a00142.html#afdfb553fa2576a3e72a6111b12f14a97" title="Currently selected speed for the mobile posture.">speed</a>;
    }
    <span class="keywordflow">else</span>
    {
        <a class="code" href="a00124.html#acf4b064a5f64a5bc493e497c1cf134ac" title="End position of current linear movement.">targetPosition</a> = <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>;
        <span class="keywordflow">if</span> (<a class="code" href="a00142.html#a6f67cb3412735ec31734d8a345688e5b" title="Variable that shows if reusing previously logged mobility pattern is requested. The value is gotten f...">useMobilityPattern</a>)
            duration = <a class="code" href="a00142.html#ae19a9a2dce220a75c4757381b5f348a7" title="The mobility pattern data base.">mobilityPattern</a>[<a class="code" href="a00142.html#aeff87bd9af8cb9aa14eada4b73ec4fbe" title="The index of the currently applied mobility pattern from.">currentPattern</a>].duration;
        <span class="keywordflow">else</span>
            duration = <a class="code" href="a00142.html#ab4f9d86a51c84b083817db1fcbe9dbab" title="Select a stay time duration in the specified range for the new posture.">selectDuration</a>();
    }
    <a class="code" href="a00147.html#a5c6e51e3ac03c935482057ce7726eb3d" title="The next simulation time when the mobility module needs to update its internal state.">nextChange</a> = simTime() + duration;

    <span class="comment">//show posture name in the graphical interface</span>
    <span class="keywordflow">if</span> (ev.isGUI()){
        <span class="keywordtype">char</span> dis_str[100];
        sprintf(dis_str,<span class="stringliteral">&quot;%s until %f&quot;</span>, <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a40dc6d7007b14e779420da389e927aec" title="Returns posture name.">getPostureName</a>(), <a class="code" href="a00147.html#a5c6e51e3ac03c935482057ce7726eb3d" title="The next simulation time when the mobility module needs to update its internal state.">nextChange</a>.dbl());
        getDisplayString().setTagArg(<span class="stringliteral">&quot;t&quot;</span>, 0, dis_str);
    }

    <span class="comment">// write the move step into the output log file</span>
    <span class="keywordflow">if</span> (<a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a7057d6de18f8fd8d646e0d370ab8c2a5" title="Check if this posture is mobile by checking the maximum possible speed.">isMobile</a>())
        fprintf(<a class="code" href="a00142.html#abb700aed062784b7cb21eec3e146c80d" title="Pointer to the file for logging MoBAN mobility pattern for future use.">logfile</a>,<span class="stringliteral">&quot;%s %d %f %f %f %f \n&quot;</span>, <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a40dc6d7007b14e779420da389e927aec" title="Returns posture name.">getPostureName</a>(), <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a217bc7334d61b9441c06affd81798445" title="Returns the unique Id (index) of this posture.">getPostureID</a>(), <a class="code" href="a00124.html#acf4b064a5f64a5bc493e497c1cf134ac" title="End position of current linear movement.">targetPosition</a>.x, <a class="code" href="a00124.html#acf4b064a5f64a5bc493e497c1cf134ac" title="End position of current linear movement.">targetPosition</a>.y, <a class="code" href="a00124.html#acf4b064a5f64a5bc493e497c1cf134ac" title="End position of current linear movement.">targetPosition</a>.z, <a class="code" href="a00142.html#afdfb553fa2576a3e72a6111b12f14a97" title="Currently selected speed for the mobile posture.">speed</a>);
    <span class="keywordflow">else</span>
        fprintf(<a class="code" href="a00142.html#abb700aed062784b7cb21eec3e146c80d" title="Pointer to the file for logging MoBAN mobility pattern for future use.">logfile</a>,<span class="stringliteral">&quot;%s %d %f \n&quot;</span>, <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a40dc6d7007b14e779420da389e927aec" title="Returns posture name.">getPostureName</a>(), <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a217bc7334d61b9441c06affd81798445" title="Returns the unique Id (index) of this posture.">getPostureID</a>(), duration.dbl());

    <a class="code" href="a00142.html#a7e5b78357b30b23f2f8285dcde5c6dd9" title="Publishes the reference point and other information of the posture to the blackboard of the belonging...">publishToNodes</a>();

    EV &lt;&lt; <span class="stringliteral">&quot;New posture: &quot;</span> &lt;&lt; <a class="code" href="a00142.html#a19a97a40859c36012f3a63a7c9ef9b46" title="The current selected posture.">currentPosture</a>-&gt;<a class="code" href="a00178.html#a40dc6d7007b14e779420da389e927aec" title="Returns posture name.">getPostureName</a>() &lt;&lt; endl;
    EV &lt;&lt; <span class="stringliteral">&quot;Destination: &quot;</span> &lt;&lt; <a class="code" href="a00124.html#acf4b064a5f64a5bc493e497c1cf134ac" title="End position of current linear movement.">targetPosition</a>.<a class="code" href="a00065.html#a86994bfa7096155d951abb03dcf30bf1" title="Returns a string with the value of the coordinate.">info</a>() &lt;&lt; <span class="stringliteral">&quot; Total Time = &quot;</span> &lt;&lt; duration &lt;&lt; endl;
}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/inet_stub/mobility/models/<a class="el" href="a00357_source.html">MoBANCoordinator.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/inet_stub/mobility/models/MoBANCoordinator.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00142.html">MoBANCoordinator</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:32 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
